import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;

public class ClientReader extends Thread {
    private final Socket socket;

    public ClientReader(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try (DataInputStream dis = new DataInputStream(socket.getInputStream())) {
            while (!socket.isClosed()) {
                String msg = dis.readUTF();
                System.out.println(msg);
            }
        } catch (IOException e) {
            System.out.println("与服务器的连接已断开");
        }
    }
}